package test;

import java.util.ArrayList;

public class BackUpClass 
{
	private ArrayList<String> arlCodeFile;
	
	public void TestMain()
	{
		//**************************************************************
	    //scan results by scope Once
//	    for (int i = 0; i < strsLocation.length; i++)
//	    {
//	    	strRtn = strRtn + scanByScopeOnce(pCntToken.getToken(), pTokenWord, strsLocation[i]);
//	    }
	    //**************************************************************
	}
	
	/*
	 * Function: Scan tokens between nearest two ";", but only once(first location of current abbreviation)
	 * Input: pToken -> Current abbreviation
	 * 		  pTokenWord -> Current abbreviation (alphabets only)
	 * 		  pLoc -> Line number in code file
	 * Output: strRtn -> Analyze result
	 */
	public String scanByScopeOnce(String pToken, String pTokenWord, String pLoc)
	{
		String strRtn = "";
		String strCodeLine = arlCodeFile.get(Integer.parseInt(pLoc.trim()) - 1);
		
		String[] strCodeTokens = strCodeLine.split(" ");
		int intIndex = 0;
		
		// find the abbreviation's location in current code line
		for (int i = 0; i < strCodeTokens.length; i++)
		{
			if (strCodeTokens[i].equals(pToken))
			{
				intIndex = i;
				break;
			}
		}
		
		// get sub string by searching the nearest ";"
		int intFront = intIndex;
		int intRear = intIndex;
		
		while (!strCodeTokens[intFront].contains(";") && intFront >= -1)
		{
			intFront --;
		}		
		while (!strCodeTokens[intRear].contains(";") && intRear <= strCodeTokens.length)
		{
			intRear ++;
		}
		
		// strCnt -> sub string
		String strCnt = "";			
		for (int i = intFront + 1; i <= intRear; i++)
		{
			strCnt = strCnt + strCodeTokens[i] + " ";
		}
		
		//strRtn = AbbCombi(pTokenWord, strCnt);
		
		//*******************************************************
					
		//System.out.println();
		//System.out.println("[" + strCnt + "] Searching for [" + pToken + "]");
		//System.out.println("Result for token [" + pToken + "] is [" + strRtn + "]");
		
		//*******************************************************
		
		return strRtn;
	}
	
	public void MainProcessor()
	{
		//nonDictionaryTokenAnalyzer.MainProcessor
		
		// before return
		//*******************************************************************		
//		for(int i = 0; i < arlHashTableKeys.size(); i ++)
//		{
//			ArrayList<tokens> arlTmp = htAlphaTokens.get(arlHashTableKeys.get(i));
//			for (int j = 0; j < arlTmp.size(); j ++)
//			{
//				System.out.println(arlHashTableKeys.get(i) + ": " + arlTmp.get(j).getToken());
//			}
//		}
		//*******************************************************************
	}
	
	/*
	 * Function: this is the recursive function for splitting token
	 * Input: pCntToken -> Current token (part of token) which needs to be split
	 * 		  pSplitLoc -> Split location for current token
	 * Output: strRtn -> Result
	 */
//	public String strSplit(String pCntToken, int pSplitLoc)
//	{
//		String strRtn = "";
//		
//		if (pCntToken.length() == 2)
//		{
//			return strReferenceScanner(pCntToken);
//		}
//		
//		String strTokenLeft = pCntToken.substring(0, pSplitLoc);
//		String strTokenRight = pCntToken.substring(pSplitLoc);
//		
//		//Check left part length first
//		if (strTokenLeft.length() != 1)
//		{
//			//left part is longer than 1, so check reference
//			String strTmpLeft = strReferenceScanner(strTokenLeft);
//			String strTmpRight = "";
//			
//			if (strTmpLeft.equals(""))
//			{
//				//No result found from reference, so need further split
//				if (pSplitLoc < pCntToken.length() - 1)
//				{
//					strRtn = strSplit(pCntToken, pSplitLoc + 1);
//				}
//				else
//				{
//					//if no split point for further split in the token, return "" back
//					return "";
//				}
//			}
//			else
//			{
//				//result found from reference, so the right part need to be deal with
//				if (strTokenRight.length() > 1)
//				{
//					strTmpRight = strReferenceScanner(strTokenRight);
//				}
//				else
//				{
//					strTmpRight = strTokenRight;
//				}
//				
//				if (strTmpRight.equals(""))
//				{
//					//No result found from reference, so need further split
//					if (2 < strTokenRight.length() - 1)
//					{
//						strRtn = strSplit(strTokenRight, 2);
//					}
//					else
//					{
//						//if no split point for further split in the token, return "" back
//						return "";
//					}
//				}
//				else
//				{
//					//Result was found for both left and right, so return the result
//					strRtn = strTmpLeft + ", " + strTmpRight;
//					return strRtn;
//				}
//			}
//		}
//		else
//		{
//			//The length of left part is 1, so abandon left part, and start to handle right part
//			String strTmpLeft = strTokenLeft;
//			String strTmpRight = "";
//			
//			if (strTokenRight.length() > 1)
//			{
//				strTmpRight = strSplit(strTokenRight, 2);
//			}
//			else
//			{
//				strTmpRight = strTokenRight;
//			}
//			
//			if (strTmpRight.equals(""))
//			{
//				//No result found from reference, so need further split
//				if (2 < strTokenRight.length() - 1)
//				{
//					strRtn = strSplit(strTokenRight, 3);
//				}
//				else
//				{
//					//if no split point for further split in the right part of token, return "" back
//					return "";
//				}
//			}
//			else
//			{
//				//Result was found for both left and right, so return the result
//				strRtn = strTmpLeft + ", " + strTmpRight;
//				return strRtn;
//			}
//			
//			//No result found from reference, so need further split
//			if (pSplitLoc < pCntToken.length() - 1)
//			{
//				strRtn = strSplit(pCntToken, pSplitLoc + 1);
//			}
//			else
//			{
//				//if no split point for further split in the token, return "" back
//				return "";
//			}
//			
//		}		
//		return strRtn;
//	}
	
//	private String strSplit2(String pCntToken, int pSplitLoc)
//	{
//		System.out.println();
//		System.out.println("Current in: " + pCntToken + ", and split at " + pSplitLoc);
//		String strRtn = "";
//		
//		//reference check for current token first
//		strRtn = strReferenceScanner(pCntToken);
//		if (!strRtn.equals(""))
//		{
//			//**********************************************************
//			System.out.println("Current reuturn(whole token scaned from reference): " + strRtn);
//			//**********************************************************
//			return strRtn;
//		}
//		
//		String strTokenLeft = pCntToken.substring(0, pSplitLoc);
//		String strTokenRight = pCntToken.substring(pSplitLoc);
//		
//		//**********************************************************
//		System.out.println("**Left Part is: " + strTokenLeft + ", and right part is: " + strTokenRight);
//		//**********************************************************
//		
//		//Check left part length first
//		//**********************************************************
//		System.out.println("Check left part length first");
//		//**********************************************************
//		if (strTokenLeft.length() != 1)
//		{
//			//left part is longer than 1, so check reference
//			//**********************************************************
//			System.out.println("left part is longer than 1, so check reference");
//			//**********************************************************
//			String strTmpLeft = strReferenceScanner(strTokenLeft);
//			String strTmpRight = "";
//			
//			if (strTmpLeft.equals(""))
//			{
//				//No result found from reference, so need check for abbreviation process 
//				/*
//				 * abbreviation process should be here
//				 */
//				
//				//No result found from abbreviation check, so need further split
//				//**********************************************************
//				System.out.println("No result found from abbreviation check, so need further split(L>1, loc+1)");
//				//**********************************************************
//				if (pSplitLoc < pCntToken.length() - 1)
//				{
//					strRtn = strSplit(pCntToken, pSplitLoc + 1);
//				}
//				else
//				{
//					//if no split point for further split in the token, return "" back
//					//********************************************************
//					System.out.println("Current reuturn: " + strRtn);
//					//**********************************************************
//					return "";
//				}
//			}
//			else
//			{
//				//result found from reference, so the right part need to be deal with
//				//scan the right part from reference first
//				//**********************************************************
//				System.out.println("result found from reference, so the right part need to be deal with, scan the right part from reference first");
//				//**********************************************************
//				if (strTokenRight.length() > 1)
//				{
//					strTmpRight = strReferenceScanner(strTokenRight);
//				}
//				else
//				{
//					strTmpRight = strTokenRight;
//				}
//				
//				if (strTmpRight.equals(""))
//				{
//					//No result found from reference, so need check for abbreviation process 
//					/*
//					 * abbreviation process should be here
//					 */
//					
//					//No result found from abbreviation check, so need to split right part
//					//**********************************************************
//					System.out.println("No result found for right part from abbreviation check, so need to split right part");
//					//**********************************************************
//					if (1 < strTokenRight.length() - 1)
//					{
//						String strTemp = strSplit(strTokenRight, 1);
//						if (!strTemp.equals(""))
//						{
//							strRtn = strTmpLeft + ", " + strTemp;
//							//********************************************************
//							System.out.println("Current reuturn: " + strRtn);
//							//**********************************************************
//							return strRtn;
//						}
//					}
//					else
//					{
//						//if no split point for further split in the token, return "" back
//						//********************************************************
//						System.out.println("Current reuturn: " + strRtn);
//						//**********************************************************
//						return "";
//					}
//				}
//				else
//				{
//					//Result was found for both left and right, so return the result
//					//**********************************************************
//					System.out.println("Result was found for both left and right, so return the result");
//					//**********************************************************
//					strRtn = strTmpLeft + ", " + strTmpRight;
//					//********************************************************
//					System.out.println("Current reuturn: " + strRtn);
//					//**********************************************************
//					return strRtn;
//				}
//			}
//		}
//		else
//		{
//			//The length of left part is 1, so abandon left part, and start to handle right part
//			//**********************************************************
//			System.out.println("The length of left part is 1, so abandon left part, and start to handle right part");
//			//**********************************************************
//			String strTmpLeft = strTokenLeft;
//			String strTmpRight = "";
//			
//			if (strTokenRight.length() > 1)
//			{
//				strTmpRight = strReferenceScanner(strTokenRight);
//			}
//			else
//			{
//				strTmpRight = strTokenRight;
//			}
//			
//			if (strTmpRight.equals(""))
//			{
//				//No result found from reference, so need check for abbreviation process 
//				/*
//				 * abbreviation process should be here
//				 */
//				
//				//No result found from abbreviation check, so need further split
//				//**********************************************************
//				System.out.println("No result found from abbreviation check, so need further split(L=1. R)");
//				//**********************************************************
//				if (2 < strTokenRight.length() - 1)
//				{
//					String strTemp = strSplit(strTokenRight, 2);
//					if (!strTemp.equals(""))
//					{
//						strRtn = strTmpLeft + ", " + strTemp;
//						//********************************************************
//						System.out.println("Current reuturn!!: " + strRtn);
//						//**********************************************************
//						return strRtn;
//					}
//				}
//				else
//				{
//					//if no split point for further split in the right part of token, return "" back
//					//********************************************************
//					System.out.println("Current reuturn: " + strRtn);
//					//**********************************************************
//					return "";
//				}
//			}
//			else
//			{
//				//Result was found for both left and right, so return the result
//				//**********************************************************
//				System.out.println("Result was found for both left and right, so return the result");
//				//**********************************************************
//				strRtn = strTmpLeft + ", " + strTmpRight;
//				//********************************************************
//				System.out.println("Current reuturn: " + strRtn);
//				//**********************************************************
//				return strRtn;
//			}
//			
//			//No result found from reference, so need further split
//			//**********************************************************
//			System.out.println("No result found from reference, so need further split(L=1, loc+1)");
//			//**********************************************************
//			if (pSplitLoc < pCntToken.length() - 1)
//			{
//				strRtn = strSplit(pCntToken, pSplitLoc + 1);
//			}
//			else
//			{
//				//if no split point for further split in the token, return "" back
//				//********************************************************
//				System.out.println("Current reuturn: " + strRtn);
//				//**********************************************************
//				return "";
//			}
//			
//		}
//		//********************************************************
//		System.out.println("Current reuturn: " + strRtn);
//		//**********************************************************
//		return strRtn;
//	}
	//version 2
//	{
//		System.out.println();
//		System.out.println("Current in: " + pCntToken + ", and split at " + pSplitLoc);
//		String strRtn = "";
//		
//		//reference check for current token first
//		strRtn = strReferenceScanner(pCntToken);
//		if (!strRtn.equals(""))
//		{
//			//**********************************************************
//			System.out.println("Current reuturn(whole token scaned from reference): " + strRtn);
//			//**********************************************************
//			return strRtn;
//		}
//		
//		String strTokenLeft = pCntToken.substring(0, pSplitLoc);
//		String strTokenRight = pCntToken.substring(pSplitLoc);
//		
//		//**********************************************************
//		System.out.println("**Left Part is: " + strTokenLeft + ", and right part is: " + strTokenRight);
//		//**********************************************************
//		
//		//Check left part length first
//		//**********************************************************
//		System.out.println("Check left part length first");
//		//**********************************************************
//		if (strTokenLeft.length() != 1)
//		{
//			//left part is longer than 1, so check reference
//			//**********************************************************
//			System.out.println("left part is longer than 1, so check reference");
//			//**********************************************************
//			String strTmpLeft = strReferenceScanner(strTokenLeft);
//			String strTmpRight = "";
//			
//			if (strTmpLeft.equals(""))
//			{
//				//No result found from reference, so need check for abbreviation process 
//				/*
//				 * abbreviation process should be here
//				 */
//				
//				//No result found from abbreviation check, so need further split
//				//**********************************************************
//				System.out.println("No result found from abbreviation check, so need further split(L>1, loc+1)");
//				//**********************************************************
//				if (pSplitLoc < pCntToken.length() - 1)
//				{
//					strRtn = strSplit(pCntToken, pSplitLoc + 1, bolIsRight);
//				}
//				else
//				{
//					//if no split point for further split in the token, return "" back
//					//********************************************************
//					System.out.println("Current reuturn: " + strRtn);
//					//**********************************************************
//					return "";
//				}
//			}
//			else
//			{
//				//result found from reference, so the right part need to be deal with
//				//scan the right part from reference first
//				//**********************************************************
//				System.out.println("result found from reference, so the right part need to be deal with, scan the right part from reference first");
//				//**********************************************************
//				if (strTokenRight.length() > 1)
//				{
//					strTmpRight = strReferenceScanner(strTokenRight);
//				}
//				else
//				{
//					strTmpRight = strTokenRight;
//				}
//				
//				if (strTmpRight.equals(""))
//				{
//					//No result found from reference, so need check for abbreviation process 
//					/*
//					 * abbreviation process should be here
//					 */
//					
//					//No result found from abbreviation check, so need to split right part
//					//**********************************************************
//					System.out.println("No result found for right part from abbreviation check, so need to split right part");
//					//**********************************************************
//					if (1 < strTokenRight.length() - 1)
//					{
//						String strTemp = strSplit(strTokenRight, 1, true);
//						if (!strTemp.equals(""))
//						{
//							strRtn = strTmpLeft + ", " + strTemp;
//							if (bolIsRight == true)
//							{
//								//********************************************************
//								System.out.println("!!!!! <1> !!!Current reuturn: " + strRtn);
//								//**********************************************************
//								return strRtn;
//							}
//							else
//							{
//								//********************************************************
//								System.out.println("!!!!! <1> !!!Save to array list: " + strRtn);
//								//**********************************************************
//								arlPossibleResults.add(strRtn);
//							}
//						}
//					}
//					else
//					{
//						//if no split point for further split in the token, return "" back
//						//********************************************************
//						System.out.println("Current reuturn: " + strRtn);
//						//**********************************************************
//						return "";
//					}
//				}
//				else
//				{
//					//Result was found for both left and right, so return the result
//					//**********************************************************
//					System.out.println("Result was found for both left and right, so return the result");
//					//**********************************************************
//					strRtn = strTmpLeft + ", " + strTmpRight;
//					if (bolIsRight == true)
//					{
//						//********************************************************
//						System.out.println("!!!!! <2> !!!Current reuturn: " + strRtn);
//						//**********************************************************
//						return strRtn;
//					}
//					else
//					{
//						//********************************************************
//						System.out.println("!!!!! <2> !!!Save to array list: " + strRtn);
//						//**********************************************************
//						arlPossibleResults.add(strRtn);
//					}
//				}
//			}
//		}
//		else
//		{
//			//The length of left part is 1, so abandon left part, and start to handle right part
//			//**********************************************************
//			System.out.println("The length of left part is 1, so abandon left part, and start to handle right part");
//			//**********************************************************
//			String strTmpLeft = strTokenLeft;
//			String strTmpRight = "";
//			
//			if (strTokenRight.length() > 1)
//			{
//				strTmpRight = strReferenceScanner(strTokenRight);
//			}
//			else
//			{
//				strTmpRight = strTokenRight;
//			}
//			
//			if (strTmpRight.equals(""))
//			{
//				//No result found from reference, so need check for abbreviation process 
//				/*
//				 * abbreviation process should be here
//				 */
//				
//				//No result found from abbreviation check, so need further split
//				//**********************************************************
//				System.out.println("No result found from abbreviation check, so need further split(L=1. R)");
//				//**********************************************************
//				if (2 < strTokenRight.length() - 1)
//				{
//					String strTemp = strSplit(strTokenRight, 2, true);
//					if (!strTemp.equals(""))
//					{
//						strRtn = strTmpLeft + ", " + strTemp;
//						if (bolIsRight == true)
//						{
//							//********************************************************
//							System.out.println("!!!!! <3> !!!Current reuturn: " + strRtn);
//							//**********************************************************
//							return strRtn;
//						}
//						else
//						{
//							//********************************************************
//							System.out.println("!!!!! <3> !!!Save to array list: " + strRtn);
//							//**********************************************************
//							arlPossibleResults.add(strRtn);
//						}
//					}
//				}
//				else
//				{
//					//if no split point for further split in the right part of token, return "" back
//					//********************************************************
//					System.out.println("Current reuturn: " + strRtn);
//					//**********************************************************
//					return "";
//				}
//			}
//			else
//			{
//				//Result was found for both left and right, so return the result
//				//**********************************************************
//				System.out.println("Result was found for both left and right, so return the result");
//				//**********************************************************
//				strRtn = strTmpLeft + ", " + strTmpRight;
//				if (bolIsRight == true)
//				{
//					//********************************************************
//					System.out.println("!!!!! <4> !!!Current reuturn: " + strRtn);
//					//**********************************************************
//					return strRtn;
//				}
//				else
//				{
//					//********************************************************
//					System.out.println("!!!!! <4> !!!Save to array list: " + strRtn);
//					//**********************************************************
//					arlPossibleResults.add(strRtn);
//				}
//			}
//			
//			//No result found from reference, so need further split
//			//**********************************************************
//			System.out.println("No result found from reference, so need further split(L=1, loc+1)");
//			//**********************************************************
//			if (pSplitLoc < pCntToken.length() - 1)
//			{
//				strRtn = strSplit(pCntToken, pSplitLoc + 1, bolIsRight);
//			}
//			else
//			{
//				//if no split point for further split in the token, return "" back
//				//********************************************************
//				System.out.println("Current reuturn: " + strRtn);
//				//**********************************************************
//				return "";
//			}
//			
//		}
//		if (bolIsRight != true)
//		{
//			while (pSplitLoc < pCntToken.length() - 1)
//			{
//				//No result found from reference, so need further split
//				//**********************************************************
//				System.out.println("No result found from reference, so need further split(END, loc+1)");
//				//**********************************************************
//				pSplitLoc = pSplitLoc + 1;
//				strRtn = strSplit(pCntToken, pSplitLoc, bolIsRight);
//			
//			}
//		}
//		//********************************************************
//		System.out.println("Current reuturn(Last): " + strRtn);
//		//**********************************************************
//		return strRtn;
//		
//	}
//	
//	
	
}
